function [IncAdv_Mat, IncAdvExpChallDem_Weighted_Holder, IncAdvExpChallRep_Weighted_Holder, IncAdvInExpChallDem_Weighted_Holder, IncAdvInExpChallRep_Weighted_Holder] = getIncAdv(Theta, VoteDem, VoterIdeal, CandTypeDem, CandTypeRep, DemCandIdeal, DemPartyIdeal, RepCandIdeal, RepPartyIdeal, RHSControls, UtilFuncParam, ChoiceProbForm, Dist_Index)

Lambdas = Theta(1:3,:);
Betas = Theta(4:6,:);
Gamma = Theta(length(Theta),:);

if length(RHSControls(1,:)) >= 1
    RHSCoeff = Theta(7:6+length(RHSControls(1,:)),:);
    SingleIndexVal = CandTypeDem(:,1:3)*Betas(1:3,:) - CandTypeRep(:,1:3)*Betas(1:3,:) + RHSControls*RHSCoeff;
else
    SingleIndexVal = CandTypeDem(:,1:3)*Betas(1:3,:) - CandTypeRep(:,1:3)*Betas(1:3,:);
end


if length(RHSControls(1,:)) >= 1
    RHSCoeff = Theta(7:6+length(RHSControls(1,:)),:);

    SingleIndexValCounterFacIncDem = Betas(1,:) - CandTypeRep(:,1:3)*Betas(1:3,:) + RHSControls*RHSCoeff;
    SingleIndexValCounterFacIncRep = CandTypeDem(:,1:3)*Betas(1:3,:) - Betas(1,:) + RHSControls*RHSCoeff;
    
    SingleIndexValCounterFacExpChallDem = Betas(2,:) - CandTypeRep(:,1:3)*Betas(1:3,:) + RHSControls*RHSCoeff;
    SingleIndexValCounterFacExpChallRep = CandTypeDem(:,1:3)*Betas(1:3,:) - Betas(2,:) + RHSControls*RHSCoeff;
    
    SingleIndexValCounterFacInExpChallDem = Betas(3,:) - CandTypeRep(:,1:3)*Betas(1:3,:) + RHSControls*RHSCoeff;
    SingleIndexValCounterFacInExpChallRep = CandTypeDem(:,1:3)*Betas(1:3,:) - Betas(3,:) + RHSControls*RHSCoeff;
    
else
    
    SingleIndexValCounterFacIncDem = Betas(1,:) - CandTypeRep(:,1:3)*Betas(1:3,:);
    SingleIndexValCounterFacIncRep = CandTypeDem(:,1:3)*Betas(1:3,:) - Betas(1,:);

    
    SingleIndexValCounterFacExpChallDem = Betas(2,:) - CandTypeRep(:,1:3)*Betas(1:3,:);
    SingleIndexValCounterFacExpChallRep = CandTypeDem(:,1:3)*Betas(1:3,:) - Betas(2,:);
    
    SingleIndexValCounterFacInExpChallDem = Betas(3,:) - CandTypeRep(:,1:3)*Betas(1:3,:);
    SingleIndexValCounterFacInExpChallRep = CandTypeDem(:,1:3)*Betas(1:3,:) - Betas(3,:);
          
end


EstPosDem=(repmat(DemCandIdeal, 1, 3).*CandTypeDem)*(1-Lambdas) + (repmat(DemPartyIdeal, 1, 3).*CandTypeDem)*(Lambdas);
EstPosRep=(repmat(RepCandIdeal, 1, 3).*CandTypeRep)*(1-Lambdas) + (repmat(RepPartyIdeal, 1, 3).*CandTypeRep)*(Lambdas);
SingleIndexPolicy = -Gamma.*abs(EstPosDem-VoterIdeal).^UtilFuncParam+Gamma.*abs(EstPosRep-VoterIdeal).^UtilFuncParam;

SingleIndex = SingleIndexPolicy + SingleIndexVal;



EstPosDemCounterFacInc = DemCandIdeal*(1-Lambdas(1,:))+DemPartyIdeal*(Lambdas(1,:));
EstPosRepCounterFacInc = RepCandIdeal*(1-Lambdas(1,:))+RepPartyIdeal*(Lambdas(1,:));

EstPosDemCounterFacExpChall = DemCandIdeal*(1-Lambdas(2,:))+DemPartyIdeal*(Lambdas(2,:));
EstPosRepCounterFacExpChall = RepCandIdeal*(1-Lambdas(2,:))+RepPartyIdeal*(Lambdas(2,:));

EstPosDemCounterFacInExpChall = DemCandIdeal*(1-Lambdas(3,:))+DemPartyIdeal*(Lambdas(3,:));
EstPosRepCounterFacInExpChall = RepCandIdeal*(1-Lambdas(3,:))+RepPartyIdeal*(Lambdas(3,:));


SingleIndexPolicyCounterFacDemInc = -Gamma.*abs(EstPosDemCounterFacInc-VoterIdeal).^UtilFuncParam+Gamma.*abs(EstPosRep-VoterIdeal).^UtilFuncParam;
SingleIndexPolicyCounterFacRepInc = -Gamma.*abs(EstPosDem-VoterIdeal).^UtilFuncParam+Gamma.*abs(EstPosRepCounterFacInc-VoterIdeal).^UtilFuncParam;

SingleIndexPolicyCounterFacDemExpChall = -Gamma.*abs(EstPosDemCounterFacExpChall-VoterIdeal).^UtilFuncParam+Gamma.*abs(EstPosRep-VoterIdeal).^UtilFuncParam;
SingleIndexPolicyCounterFacRepExpChall = -Gamma.*abs(EstPosDem-VoterIdeal).^UtilFuncParam+Gamma.*abs(EstPosRepCounterFacExpChall-VoterIdeal).^UtilFuncParam;

SingleIndexPolicyCounterFacDemInExpChall = -Gamma.*abs(EstPosDemCounterFacInExpChall-VoterIdeal).^UtilFuncParam+Gamma.*abs(EstPosRep-VoterIdeal).^UtilFuncParam;
SingleIndexPolicyCounterFacRepInExpChall = -Gamma.*abs(EstPosDem-VoterIdeal).^UtilFuncParam+Gamma.*abs(EstPosRepCounterFacInExpChall-VoterIdeal).^UtilFuncParam;

SingleIndexCounterFacDemInc = SingleIndexPolicyCounterFacDemInc + SingleIndexValCounterFacIncDem;
SingleIndexCounterFacRepInc = SingleIndexPolicyCounterFacRepInc + SingleIndexValCounterFacIncRep;

SingleIndexCounterFacDemExpChall = SingleIndexPolicyCounterFacDemExpChall + SingleIndexValCounterFacExpChallDem;
SingleIndexCounterFacRepExpChall = SingleIndexPolicyCounterFacRepExpChall + SingleIndexValCounterFacExpChallRep;

SingleIndexCounterFacDemInExpChall = SingleIndexPolicyCounterFacDemInExpChall + SingleIndexValCounterFacInExpChallDem;
SingleIndexCounterFacRepInExpChall = SingleIndexPolicyCounterFacRepInExpChall + SingleIndexValCounterFacInExpChallRep;

SingleIndexCounterFacDemInc_NoDir = SingleIndexPolicyCounterFacDemInc + SingleIndexVal;
SingleIndexCounterFacRepInc_NoDir = SingleIndexPolicyCounterFacRepInc + SingleIndexVal;

SingleIndexCounterFacDemExpChall_NoDir = SingleIndexPolicyCounterFacDemExpChall + SingleIndexVal;
SingleIndexCounterFacRepExpChall_NoDir = SingleIndexPolicyCounterFacRepExpChall + SingleIndexVal;

SingleIndexCounterFacDemInExpChall_NoDir = SingleIndexPolicyCounterFacDemExpChall + SingleIndexVal;
SingleIndexCounterFacRepInExpChall_NoDir = SingleIndexPolicyCounterFacRepExpChall + SingleIndexVal;

SingleIndexCounterFacDemInc_OnlyVal = SingleIndexPolicy + SingleIndexValCounterFacIncDem;
SingleIndexCounterFacRepInc_OnlyVal = SingleIndexPolicy + SingleIndexValCounterFacIncRep;

SingleIndexCounterFacDemExpChall_OnlyVal = SingleIndexPolicy + SingleIndexValCounterFacExpChallDem;
SingleIndexCounterFacRepExpChall_OnlyVal = SingleIndexPolicy + SingleIndexValCounterFacExpChallRep;

SingleIndexCounterFacDemInExpChall_OnlyVal = SingleIndexPolicy + SingleIndexValCounterFacInExpChallDem;
SingleIndexCounterFacRepInExpChall_OnlyVal = SingleIndexPolicy + SingleIndexValCounterFacInExpChallRep;


if ChoiceProbForm == 1

    PrVoteLeft = normcdf(SingleIndex, 0, 1);
    
    PrVoteLeftCounterFacDemInc = normcdf(SingleIndexCounterFacDemInc, 0, 1);
    PrVoteLeftCounterFacRepInc = normcdf(SingleIndexCounterFacRepInc, 0, 1);
    
    PrVoteLeftCounterFacDemInc_NoDir = normcdf(SingleIndexCounterFacDemInc_NoDir, 0, 1);
    PrVoteLeftCounterFacRepInc_NoDir = normcdf(SingleIndexCounterFacRepInc_NoDir, 0, 1);

    PrVoteLeftCounterFacDemInc_OnlyVal = normcdf(SingleIndexCounterFacDemInc_OnlyVal, 0, 1);
    PrVoteLeftCounterFacRepInc_OnlyVal = normcdf(SingleIndexCounterFacRepInc_OnlyVal, 0, 1);
    
    PrVoteLeftCounterFacDemExpChall = normcdf(SingleIndexCounterFacDemExpChall, 0, 1);
    PrVoteLeftCounterFacRepExpChall = normcdf(SingleIndexCounterFacRepExpChall, 0, 1);
    
    PrVoteLeftCounterFacDemExpChall_NoDir = normcdf(SingleIndexCounterFacDemExpChall_NoDir, 0, 1);
    PrVoteLeftCounterFacRepExpChall_NoDir = normcdf(SingleIndexCounterFacRepExpChall_NoDir, 0, 1);

    PrVoteLeftCounterFacDemExpChall_OnlyVal = normcdf(SingleIndexCounterFacDemExpChall_OnlyVal, 0, 1);
    PrVoteLeftCounterFacRepExpChall_OnlyVal = normcdf(SingleIndexCounterFacRepExpChall_OnlyVal, 0, 1);
        
    PrVoteLeftCounterFacDemInExpChall = normcdf(SingleIndexCounterFacDemInExpChall, 0, 1);
    PrVoteLeftCounterFacRepInExpChall = normcdf(SingleIndexCounterFacRepInExpChall, 0, 1);

    PrVoteLeftCounterFacDemInExpChall_NoDir = normcdf(SingleIndexCounterFacDemInExpChall_NoDir, 0, 1);
    PrVoteLeftCounterFacRepInExpChall_NoDir = normcdf(SingleIndexCounterFacRepInExpChall_NoDir, 0, 1);

    PrVoteLeftCounterFacDemInExpChall_OnlyVal = normcdf(SingleIndexCounterFacDemInExpChall_OnlyVal, 0, 1);
    PrVoteLeftCounterFacRepInExpChall_OnlyVal = normcdf(SingleIndexCounterFacRepInExpChall_OnlyVal, 0, 1);
    
    
elseif ChoiceProbForm == 2
    
    PrVoteLeft = exp(SingleIndex)./(1+exp(SingleIndex)); 

    PrVoteLeftCounterFacDemInc = exp(SingleIndexCounterFacDemInc)./(1+exp(SingleIndexCounterFacDemInc));
    PrVoteLeftCounterFacRepInc = exp(SingleIndexCounterFacRepInc)./(1+exp(SingleIndexCounterFacRepInc));
    PrVoteLeftCounterFacDemInc_NoDir = exp(SingleIndexCounterFacDemInc_NoDir)./(1+exp(SingleIndexCounterFacDemInc_NoDir));
    PrVoteLeftCounterFacRepInc_NoDir = exp(SingleIndexCounterFacRepInc_NoDir)./(1+exp(SingleIndexCounterFacRepInc_NoDir)); 
    PrVoteLeftCounterFacDemInc_OnlyVal = exp(SingleIndexCounterFacDemInc_OnlyVal)./(1+exp(SingleIndexCounterFacDemInc_OnlyVal));
    PrVoteLeftCounterFacRepInc_OnlyVal = exp(SingleIndexCounterFacRepInc_OnlyVal)./(1+exp(SingleIndexCounterFacRepInc_OnlyVal));

    
    PrVoteLeftCounterFacDemExpChall = exp(SingleIndexCounterFacDemExpChall)./(1+exp(SingleIndexCounterFacDemExpChall));
    PrVoteLeftCounterFacRepExpChall = exp(SingleIndexCounterFacRepExpChall)./(1+exp(SingleIndexCounterFacRepExpChall));
    PrVoteLeftCounterFacDemExpChall_NoDir = exp(SingleIndexCounterFacDemExpChall_NoDir)./(1+exp(SingleIndexCounterFacDemExpChall_NoDir));
    PrVoteLeftCounterFacRepExpChall_NoDir = exp(SingleIndexCounterFacRepExpChall_NoDir)./(1+exp(SingleIndexCounterFacRepExpChall_NoDir)); 
    PrVoteLeftCounterFacDemExpChall_OnlyVal = exp(SingleIndexCounterFacDemExpChall_OnlyVal)./(1+exp(SingleIndexCounterFacDemExpChall_OnlyVal));
    PrVoteLeftCounterFacRepExpChall_OnlyVal = exp(SingleIndexCounterFacRepExpChall_OnlyVal)./(1+exp(SingleIndexCounterFacRepExpChall_OnlyVal)); 

    
    PrVoteLeftCounterFacDemInExpChall = exp(SingleIndexCounterFacDemInExpChall)./(1+exp(SingleIndexCounterFacDemInExpChall));
    PrVoteLeftCounterFacRepInExpChall = exp(SingleIndexCounterFacRepInExpChall)./(1+exp(SingleIndexCounterFacRepInExpChall));
    PrVoteLeftCounterFacDemInExpChall_NoDir = exp(SingleIndexCounterFacDemInExpChall_NoDir)./(1+exp(SingleIndexCounterFacDemInExpChall_NoDir));
    PrVoteLeftCounterFacRepInExpChall_NoDir = exp(SingleIndexCounterFacRepInExpChall_NoDir)./(1+exp(SingleIndexCounterFacRepInExpChall_NoDir)); 
    PrVoteLeftCounterFacDemInExpChall_OnlyVal = exp(SingleIndexCounterFacDemInExpChall_OnlyVal)./(1+exp(SingleIndexCounterFacDemInExpChall_OnlyVal));
    PrVoteLeftCounterFacRepInExpChall_OnlyVal = exp(SingleIndexCounterFacRepInExpChall_OnlyVal)./(1+exp(SingleIndexCounterFacRepInExpChall_OnlyVal)); 
    
end


ExpChalltoIncDem_Total = PrVoteLeftCounterFacDemInc(CandTypeDem(:,2)==1,:) - PrVoteLeft(CandTypeDem(:,2)==1,:);
ExpChalltoIncRep_Total = -(PrVoteLeftCounterFacRepInc(CandTypeRep(:,2)==1,:) - PrVoteLeft(CandTypeRep(:,2)==1,:));

ExpChalltoIncDem_Sig = PrVoteLeftCounterFacDemInc_NoDir(CandTypeDem(:,2)==1,:) - PrVoteLeft(CandTypeDem(:,2)==1,:);
ExpChalltoIncRep_Sig = -(PrVoteLeftCounterFacRepInc_NoDir(CandTypeRep(:,2)==1,:) - PrVoteLeft(CandTypeRep(:,2)==1,:));

InExpChalltoIncDem_Total = PrVoteLeftCounterFacDemInc(CandTypeDem(:,3)==1,:) - PrVoteLeft(CandTypeDem(:,3)==1,:);
InExpChalltoIncRep_Total = -(PrVoteLeftCounterFacRepInc(CandTypeRep(:,3)==1,:) - PrVoteLeft(CandTypeRep(:,3)==1,:));

InExpChalltoIncDem_Sig = PrVoteLeftCounterFacDemInc_NoDir(CandTypeDem(:,3)==1,:) - PrVoteLeft(CandTypeDem(:,3)==1,:);
InExpChalltoIncRep_Sig = -(PrVoteLeftCounterFacRepInc_NoDir(CandTypeRep(:,3)==1,:) - PrVoteLeft(CandTypeRep(:,3)==1,:));

IncAdvExpChallDem_Total = PrVoteLeft(CandTypeDem(:,1)==1,:)-PrVoteLeftCounterFacDemExpChall(CandTypeDem(:,1)==1,:);
IncAdvExpChallRep_Total = -(PrVoteLeft(CandTypeRep(:,1)==1,:)-PrVoteLeftCounterFacRepExpChall(CandTypeRep(:,1)==1,:));

IncAdvExpChallDem_Sig = PrVoteLeft(CandTypeDem(:,1)==1,:)-PrVoteLeftCounterFacDemExpChall_NoDir(CandTypeDem(:,1)==1,:);
IncAdvExpChallRep_Sig = -(PrVoteLeft(CandTypeRep(:,1)==1,:)-PrVoteLeftCounterFacRepExpChall_NoDir(CandTypeRep(:,1)==1,:));

IncAdvInExpChallDem_Total = PrVoteLeft(CandTypeDem(:,1)==1,:)-PrVoteLeftCounterFacDemInExpChall(CandTypeDem(:,1)==1,:);
IncAdvInExpChallRep_Total = -(PrVoteLeft(CandTypeRep(:,1)==1,:)-PrVoteLeftCounterFacRepInExpChall(CandTypeRep(:,1)==1,:));

IncAdvInExpChallDem_Sig = PrVoteLeft(CandTypeDem(:,1)==1,:)-PrVoteLeftCounterFacDemInExpChall_NoDir(CandTypeDem(:,1)==1,:);
IncAdvInExpChallRep_Sig = -(PrVoteLeft(CandTypeRep(:,1)==1,:)-PrVoteLeftCounterFacRepInExpChall_NoDir(CandTypeRep(:,1)==1,:));

%Weighting by District

ExpChalltoIncDem_Weighted_Holder = zeros(max(Dist_Index), 1);
ExpChalltoIncRep_Weighted_Holder = zeros(max(Dist_Index), 1);

ExpChalltoIncDem_Sig_Weighted_Holder = zeros(max(Dist_Index), 1);
ExpChalltoIncRep_Sig_Weighted_Holder = zeros(max(Dist_Index), 1);

ExpChalltoIncDem_Val_Weighted_Holder = zeros(max(Dist_Index), 1);
ExpChalltoIncRep_Val_Weighted_Holder = zeros(max(Dist_Index), 1);


InExpChalltoIncDem_Weighted_Holder = zeros(max(Dist_Index), 1);
InExpChalltoIncRep_Weighted_Holder = zeros(max(Dist_Index), 1);

InExpChalltoIncDem_Sig_Weighted_Holder = zeros(max(Dist_Index), 1);
InExpChalltoIncRep_Sig_Weighted_Holder = zeros(max(Dist_Index), 1);

InExpChalltoIncDem_Val_Weighted_Holder = zeros(max(Dist_Index), 1);
InExpChalltoIncRep_Val_Weighted_Holder = zeros(max(Dist_Index), 1);

IncAdvExpChallDem_Weighted_Holder = zeros(max(Dist_Index), 1);
IncAdvExpChallRep_Weighted_Holder = zeros(max(Dist_Index), 1);

IncAdvExpChallDem_Sig_Weighted_Holder = zeros(max(Dist_Index), 1);
IncAdvExpChallRep_Sig_Weighted_Holder = zeros(max(Dist_Index), 1);

IncAdvExpChallDem_Val_Weighted_Holder = zeros(max(Dist_Index), 1);
IncAdvExpChallRep_Val_Weighted_Holder = zeros(max(Dist_Index), 1);

IncAdvInExpChallDem_Weighted_Holder = zeros(max(Dist_Index), 1);
IncAdvInExpChallRep_Weighted_Holder = zeros(max(Dist_Index), 1);

IncAdvInExpChallDem_Sig_Weighted_Holder = zeros(max(Dist_Index), 1);
IncAdvInExpChallRep_Sig_Weighted_Holder = zeros(max(Dist_Index), 1);

IncAdvInExpChallDem_Val_Weighted_Holder = zeros(max(Dist_Index), 1);
IncAdvInExpChallRep_Val_Weighted_Holder = zeros(max(Dist_Index), 1);

for d = 1:max(Dist_Index)
    
    ExpChalltoIncDem_Weighted_Holder(d,:) = sum(PrVoteLeftCounterFacDemInc(Dist_Index==d & CandTypeDem(:,2)==1,:) - PrVoteLeft(Dist_Index==d & CandTypeDem(:,2)==1,:))/sum(Dist_Index==d & CandTypeDem(:,2) == 1);
    ExpChalltoIncRep_Weighted_Holder(d,:) =  sum(-(PrVoteLeftCounterFacRepInc(Dist_Index==d & CandTypeRep(:,2)==1,:) - PrVoteLeft(Dist_Index==d & CandTypeRep(:,2)==1,:)))/sum(Dist_Index==d & CandTypeRep(:,2) == 1);

    ExpChalltoIncDem_Sig_Weighted_Holder(d,:) = sum(PrVoteLeftCounterFacDemInc_NoDir(Dist_Index==d & CandTypeDem(:,2)==1,:) - PrVoteLeft(Dist_Index==d & CandTypeDem(:,2)==1,:))/sum(Dist_Index==d & CandTypeDem(:,2) == 1);
    ExpChalltoIncRep_Sig_Weighted_Holder(d,:) = sum(-(PrVoteLeftCounterFacRepInc_NoDir(Dist_Index==d & CandTypeRep(:,2)==1,:) - PrVoteLeft(Dist_Index==d & CandTypeRep(:,2)==1,:)))/sum(Dist_Index==d & CandTypeRep(:,2) == 1);

    ExpChalltoIncDem_Val_Weighted_Holder(d,:) = sum(PrVoteLeftCounterFacDemInc_OnlyVal(Dist_Index==d & CandTypeDem(:,2)==1,:) - PrVoteLeft(Dist_Index==d & CandTypeDem(:,2)==1,:))/sum(Dist_Index==d & CandTypeDem(:,2) == 1);
    ExpChalltoIncRep_Val_Weighted_Holder(d,:) = sum(-(PrVoteLeftCounterFacRepInc_OnlyVal(Dist_Index==d & CandTypeRep(:,2)==1,:) - PrVoteLeft(Dist_Index==d & CandTypeRep(:,2)==1,:)))/sum(Dist_Index==d & CandTypeRep(:,2) == 1);

    InExpChalltoIncDem_Weighted_Holder(d,:) = sum(PrVoteLeftCounterFacDemInc(Dist_Index==d & CandTypeDem(:,3)==1,:) - PrVoteLeft(Dist_Index==d & CandTypeDem(:,3)==1,:))/sum(Dist_Index==d & CandTypeDem(:,3) == 1);
    InExpChalltoIncRep_Weighted_Holder(d,:) = sum(-(PrVoteLeftCounterFacRepInc(Dist_Index==d & CandTypeRep(:,3)==1,:) - PrVoteLeft(Dist_Index==d & CandTypeRep(:,3)==1,:)))/sum(Dist_Index==d & CandTypeRep(:,3) == 1);
 
    InExpChalltoIncDem_Sig_Weighted_Holder(d,:) = sum(PrVoteLeftCounterFacDemInc_NoDir(Dist_Index==d & CandTypeDem(:,3)==1,:) - PrVoteLeft(Dist_Index==d & CandTypeDem(:,3)==1,:))/sum(Dist_Index==d & CandTypeDem(:,3) == 1);
    InExpChalltoIncRep_Sig_Weighted_Holder(d,:) = sum(-(PrVoteLeftCounterFacRepInc_NoDir(Dist_Index==d & CandTypeRep(:,3)==1,:) - PrVoteLeft(Dist_Index==d & CandTypeRep(:,3)==1,:)))/sum(Dist_Index==d & CandTypeRep(:,3) == 1);
    
    InExpChalltoIncDem_Val_Weighted_Holder(d,:) = sum(PrVoteLeftCounterFacDemInc_OnlyVal(Dist_Index==d & CandTypeDem(:,3)==1,:) - PrVoteLeft(Dist_Index==d & CandTypeDem(:,3)==1,:))/sum(Dist_Index==d & CandTypeDem(:,3) == 1);
    InExpChalltoIncRep_Val_Weighted_Holder(d,:) = sum(-(PrVoteLeftCounterFacRepInc_OnlyVal(Dist_Index==d & CandTypeRep(:,3)==1,:) - PrVoteLeft(Dist_Index==d & CandTypeRep(:,3)==1,:)))/sum(Dist_Index==d & CandTypeRep(:,3) == 1);
        
    IncAdvExpChallDem_Weighted_Holder(d,:) = sum(PrVoteLeft(Dist_Index==d & CandTypeDem(:,1) == 1,:)-PrVoteLeftCounterFacDemExpChall(Dist_Index==d & CandTypeDem(:,1) == 1,:))/sum(Dist_Index==d & CandTypeDem(:,1) == 1);
    IncAdvExpChallRep_Weighted_Holder(d,:) = sum(-(PrVoteLeft(Dist_Index==d & CandTypeRep(:,1) == 1,:)-PrVoteLeftCounterFacRepExpChall(Dist_Index==d & CandTypeRep(:,1) == 1,:)))/sum(Dist_Index==d & CandTypeRep(:,1) == 1);

    IncAdvExpChallDem_Sig_Weighted_Holder(d,:) = sum(PrVoteLeft(Dist_Index==d & CandTypeDem(:,1)==1,:)-PrVoteLeftCounterFacDemExpChall_NoDir(Dist_Index==d & CandTypeDem(:,1)==1,:))/sum(Dist_Index==d & CandTypeDem(:,1) == 1);
    IncAdvExpChallRep_Sig_Weighted_Holder(d,:) = sum(-(PrVoteLeft(Dist_Index==d & CandTypeRep(:,1)==1,:)-PrVoteLeftCounterFacRepExpChall_NoDir(Dist_Index==d & CandTypeRep(:,1)==1,:)))/sum(Dist_Index==d & CandTypeRep(:,1) == 1);

    IncAdvExpChallDem_Val_Weighted_Holder(d,:) = sum(PrVoteLeft(Dist_Index==d & CandTypeDem(:,1)==1,:)-PrVoteLeftCounterFacDemExpChall_OnlyVal(Dist_Index==d & CandTypeDem(:,1)==1,:))/sum(Dist_Index==d & CandTypeDem(:,1) == 1);
    IncAdvExpChallRep_Val_Weighted_Holder(d,:) = sum(-(PrVoteLeft(Dist_Index==d & CandTypeRep(:,1)==1,:)-PrVoteLeftCounterFacRepExpChall_OnlyVal(Dist_Index==d & CandTypeRep(:,1)==1,:)))/sum(Dist_Index==d & CandTypeRep(:,1) == 1);

    IncAdvInExpChallDem_Weighted_Holder(d,:) = sum(PrVoteLeft(Dist_Index==d & CandTypeDem(:,1)==1,:)-PrVoteLeftCounterFacDemInExpChall(Dist_Index==d & CandTypeDem(:,1)==1,:))/sum(Dist_Index==d & CandTypeDem(:,1) == 1);
    IncAdvInExpChallRep_Weighted_Holder(d,:) = sum(-(PrVoteLeft(Dist_Index==d & CandTypeRep(:,1) == 1,:)-PrVoteLeftCounterFacRepInExpChall(Dist_Index==d & CandTypeRep(:,1) == 1,:)))/sum(Dist_Index==d & CandTypeRep(:,1) == 1);

    IncAdvInExpChallDem_Sig_Weighted_Holder(d,:) = sum(PrVoteLeft(Dist_Index==d & CandTypeDem(:,1)==1,:)-PrVoteLeftCounterFacDemInExpChall_NoDir(Dist_Index==d & CandTypeDem(:,1)==1,:))/sum(Dist_Index==d & CandTypeDem(:,1) == 1);
    IncAdvInExpChallRep_Sig_Weighted_Holder(d,:) = sum(-(PrVoteLeft(Dist_Index==d & CandTypeRep(:,1)==1,:)-PrVoteLeftCounterFacRepInExpChall_NoDir(Dist_Index==d & CandTypeRep(:,1)==1,:)))/sum(Dist_Index==d & CandTypeRep(:,1) == 1);

    IncAdvInExpChallDem_Val_Weighted_Holder(d,:) = sum(PrVoteLeft(Dist_Index==d & CandTypeDem(:,1)==1,:)-PrVoteLeftCounterFacDemInExpChall_OnlyVal(Dist_Index==d & CandTypeDem(:,1)==1,:))/sum(Dist_Index==d & CandTypeDem(:,1) == 1);
    IncAdvInExpChallRep_Val_Weighted_Holder(d,:) = sum(-(PrVoteLeft(Dist_Index==d & CandTypeRep(:,1)==1,:)-PrVoteLeftCounterFacRepInExpChall_OnlyVal(Dist_Index==d & CandTypeRep(:,1)==1,:)))/sum(Dist_Index==d & CandTypeRep(:,1) == 1);

end

ExpChalltoIncDem_Weighted = mean(ExpChalltoIncDem_Weighted_Holder(isnan(ExpChalltoIncDem_Weighted_Holder) == 0));
ExpChalltoIncRep_Weighted = mean(ExpChalltoIncRep_Weighted_Holder(isnan(ExpChalltoIncRep_Weighted_Holder) == 0));

ExpChalltoIncDem_Sig_Weighted = mean(ExpChalltoIncDem_Sig_Weighted_Holder(isnan(ExpChalltoIncDem_Sig_Weighted_Holder) == 0));
ExpChalltoIncRep_Sig_Weighted = mean(ExpChalltoIncRep_Sig_Weighted_Holder(isnan(ExpChalltoIncRep_Sig_Weighted_Holder) == 0));

ExpChalltoIncDem_Val_Weighted = mean(ExpChalltoIncDem_Val_Weighted_Holder(isnan(ExpChalltoIncDem_Val_Weighted_Holder) == 0));
ExpChalltoIncRep_Val_Weighted = mean(ExpChalltoIncRep_Val_Weighted_Holder(isnan(ExpChalltoIncRep_Val_Weighted_Holder) == 0));

InExpChalltoIncDem_Weighted = mean(InExpChalltoIncDem_Weighted_Holder(isnan(InExpChalltoIncDem_Weighted_Holder) == 0));
InExpChalltoIncRep_Weighted = mean(InExpChalltoIncRep_Weighted_Holder(isnan(InExpChalltoIncRep_Weighted_Holder) == 0));

InExpChalltoIncDem_Sig_Weighted = mean(InExpChalltoIncDem_Sig_Weighted_Holder(isnan(InExpChalltoIncDem_Sig_Weighted_Holder) == 0));
InExpChalltoIncRep_Sig_Weighted = mean(InExpChalltoIncRep_Sig_Weighted_Holder(isnan(InExpChalltoIncRep_Sig_Weighted_Holder) == 0));

InExpChalltoIncDem_Val_Weighted = mean(InExpChalltoIncDem_Val_Weighted_Holder(isnan(InExpChalltoIncDem_Val_Weighted_Holder) == 0));
InExpChalltoIncRep_Val_Weighted = mean(InExpChalltoIncRep_Val_Weighted_Holder(isnan(InExpChalltoIncRep_Val_Weighted_Holder) == 0));

IncAdvExpChallDem_Weighted = mean(IncAdvExpChallDem_Weighted_Holder(isnan(IncAdvExpChallDem_Weighted_Holder) == 0));
IncAdvExpChallRep_Weighted = mean(IncAdvExpChallRep_Weighted_Holder(isnan(IncAdvExpChallRep_Weighted_Holder) == 0));

IncAdvExpChallDem_Sig_Weighted = mean(IncAdvExpChallDem_Sig_Weighted_Holder(isnan(IncAdvExpChallDem_Sig_Weighted_Holder) == 0));
IncAdvExpChallRep_Sig_Weighted = mean(IncAdvExpChallRep_Sig_Weighted_Holder(isnan(IncAdvExpChallRep_Sig_Weighted_Holder) == 0));

IncAdvExpChallDem_Val_Weighted = mean(IncAdvExpChallDem_Val_Weighted_Holder(isnan(IncAdvExpChallDem_Val_Weighted_Holder) == 0));
IncAdvExpChallRep_Val_Weighted = mean(IncAdvExpChallRep_Val_Weighted_Holder(isnan(IncAdvExpChallRep_Val_Weighted_Holder) == 0));

IncAdvInExpChallDem_Weighted = mean(IncAdvInExpChallDem_Weighted_Holder(isnan(IncAdvInExpChallDem_Weighted_Holder) == 0));
IncAdvInExpChallRep_Weighted = mean(IncAdvInExpChallRep_Weighted_Holder(isnan(IncAdvInExpChallRep_Weighted_Holder) == 0));

IncAdvInExpChallDem_Sig_Weighted = mean(IncAdvInExpChallDem_Sig_Weighted_Holder(isnan(IncAdvInExpChallDem_Sig_Weighted_Holder) == 0));
IncAdvInExpChallRep_Sig_Weighted = mean(IncAdvInExpChallRep_Sig_Weighted_Holder(isnan(IncAdvInExpChallRep_Sig_Weighted_Holder) == 0));

IncAdvInExpChallDem_Val_Weighted = mean(IncAdvInExpChallDem_Val_Weighted_Holder(isnan(IncAdvInExpChallDem_Val_Weighted_Holder) == 0));
IncAdvInExpChallRep_Val_Weighted = mean(IncAdvInExpChallRep_Val_Weighted_Holder(isnan(IncAdvInExpChallRep_Val_Weighted_Holder) == 0));

SigDecomp_ExpChalltoIncDem = ExpChalltoIncDem_Sig_Weighted/ExpChalltoIncDem_Weighted;
SigDecomp_ExpChalltoIncRep = ExpChalltoIncRep_Sig_Weighted/ExpChalltoIncRep_Weighted;

SigDecomp_InExpChalltoIncDem = InExpChalltoIncDem_Sig_Weighted/InExpChalltoIncDem_Weighted;
SigDecomp_InExpChalltoIncRep = InExpChalltoIncRep_Sig_Weighted/InExpChalltoIncRep_Weighted;

SigDecomp_IncAdvExpChallDem = IncAdvExpChallDem_Sig_Weighted/IncAdvExpChallDem_Weighted;
SigDecomp_IncAdvExpChallRep = IncAdvExpChallRep_Sig_Weighted/IncAdvExpChallRep_Weighted;

SigDecomp_IncAdvInExpChallDem = IncAdvInExpChallDem_Sig_Weighted/IncAdvInExpChallDem_Weighted;
SigDecomp_IncAdvInExpChallRep = IncAdvInExpChallRep_Sig_Weighted/IncAdvInExpChallRep_Weighted;

IncAdv_Mat = vertcat(IncAdvExpChallDem_Weighted, IncAdvExpChallRep_Weighted, IncAdvInExpChallDem_Weighted, IncAdvInExpChallRep_Weighted, ExpChalltoIncDem_Weighted, ExpChalltoIncRep_Weighted, InExpChalltoIncDem_Weighted, InExpChalltoIncRep_Weighted, SigDecomp_IncAdvExpChallDem, SigDecomp_IncAdvExpChallRep, SigDecomp_IncAdvInExpChallDem, SigDecomp_IncAdvInExpChallRep, SigDecomp_ExpChalltoIncDem, SigDecomp_ExpChalltoIncRep, SigDecomp_InExpChalltoIncDem, SigDecomp_InExpChalltoIncRep, IncAdvExpChallDem_Val_Weighted, IncAdvExpChallRep_Val_Weighted, IncAdvInExpChallDem_Val_Weighted, IncAdvInExpChallRep_Val_Weighted, ExpChalltoIncDem_Val_Weighted, ExpChalltoIncRep_Val_Weighted, InExpChalltoIncDem_Val_Weighted, InExpChalltoIncRep_Val_Weighted);